﻿using System;
using System.Text;
using System.Collections;
using System.Xml;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Resources;
using System.Reflection;
using System.Globalization;
using System.Threading;

using Telerik.WebControls;
using UFSoft.UBF.UI.WebControls;
using UFSoft.UBF.UI.Controls;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.Util.Globalization;

using UFSoft.UBF.UI.IView;
using UFSoft.UBF.UI.Engine;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFSoft.UBF.UI.WebControls.ClientCallBack;
using UFIDA.U9.Learn.ItemBP.Proxy;
using UFIDA.U9.Learn.ItemBP;
using System.Collections.Generic;



/***********************************************************************************************
 * Form ID: 
 * UIFactory Auto Generator 
 ***********************************************************************************************/
namespace QCGuideUpdateUIModel
{
    public partial class QCGuideUpdateFormWebPart
    {
        #region Custome eventBind
	
		 

			

		//QCGuideLine198_TextChanged...
		private void QCGuideLine198_TextChanged_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			if (this.Model.QCGuideMainView.FocusedRecord == null)
				throw new Exception("当前数据为空");
			if (this.Model.QCGuideMainView.FocusedRecord.QCGuideLine1 == null)
				throw new Exception("请先录入旧指标");
			QCSchemaQueryProxy proxy=new QCSchemaQueryProxy();
			proxy.QCGuideLineID = this.Model.QCGuideMainView.FocusedRecord.QCGuideLine1??0;
            System.Collections.Generic.List<UFIDA.U9.Learn.ItemBP.QCSchemaDTOData> qCSchemaDTODatas = proxy.Do();
			foreach(var item in qCSchemaDTODatas)
            {
                QCGuideLineViewRecord newitem = this.Model.QCGuideLineView.AddNewUIRecord();
				newitem.QCSchema = item.ID;
				newitem.QCSchema_Code = item.Code;
				newitem.QCSchema_Name = item.Name;
				newitem.Version = item.Version;
				//newitem.QCGuideMainView_ID = this.Model.QCGuideMainView.FocusedRecord.ID;
				newitem.SetParentRecord(this.Model.QCGuideMainView?.FocusedRecord);
            }

            QCGuideLine198_TextChanged_DefaultImpl(sender,e);
		}	
		 
				//UpdateClick378_Click...
		private void UpdateClick378_Click_Extend(object sender, EventArgs  e)
		{
			//调用模版提供的默认实现.--默认实现可能会调用相应的Action.
			if (this.Model.QCGuideMainView.FocusedRecord == null)
				throw new Exception("当前数据为空");
			if (this.Model.QCGuideMainView.FocusedRecord.QCGuideLine1 == null)
				throw new Exception("请先录入旧指标");
			if (this.Model.QCGuideMainView.FocusedRecord.QCGuideLine2 == null)
				throw new Exception("请先录入新指标");
			List<QCSchemaDTOData> inlist = new List<QCSchemaDTOData>();
			foreach (var item in this.Model.QCGuideLineView.Records)
            {
				QCGuideLineViewRecord item1=item as QCGuideLineViewRecord; 
				QCSchemaDTOData dto=new QCSchemaDTOData();
				dto.ID = item1.QCSchema;
				dto.Code = item1.QCSchema_Code;
				dto.Name= item1.QCSchema_Name;
				inlist.Add(dto);
			}

			QCGuideUpdateProxy proxy = new QCGuideUpdateProxy();
			proxy.QCSchema = inlist;
            int cnt = proxy.Do();

			UpdateClick378_Click_DefaultImpl(sender,e);
		}

		
            
            

		#region 自定义数据初始化加载和数据收集
		private void OnLoadData_Extend(object sender)
		{	
			OnLoadData_DefaultImpl(sender);
		}
		private void OnDataCollect_Extend(object sender)
		{	
			OnDataCollect_DefaultImpl(sender);
		}
		#endregion  

        #region 自己扩展 Extended Event handler 
		public void AfterOnLoad()
		{

		}

        public void AfterCreateChildControls()
        {


		
        }
        
        public void AfterEventBind()
        {
        }
        
		public void BeforeUIModelBinding()
		{

		}

		public void AfterUIModelBinding()
		{


		}


        #endregion
		
        #endregion
		
    }
}